From b6577527179dd544a35f23b31df16d47e664c070 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 24 Mar 2021 08:16:24 -0600 Subject: [PATCH] fix some format mismatches found by PVS-Studio V576 Incorrect format. Consider checking the second actual argument of the 'asprintf' function. The SIGNED integer type argument is expected. QString::asprintf is not recommended for new code anyway. --- mtk_logger.cc | 2 +- skytraq.cc | 2 +- waypt.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mtk_logger.cc b/mtk_logger.cc index 0c8bb9d76..6a36421bc 100644 --- a/mtk_logger.cc +++ b/mtk_logger.cc @@ -901,7 +901,7 @@ static int add_trackpoint(int idx, unsigned long bmask, struct data_item* itm) /* Button press -- create waypoint, start count at 1 */ auto* w = new Waypoint(*trk); - w->shortname = QString::asprintf("WP%06d", waypt_count()+1); + w->shortname = QString("WP%1").arg(waypt_count() + 1, 6, 10, QLatin1Char('0')); waypt_add(w); } // In theory we would not add the waypoint to the list of diff --git a/skytraq.cc b/skytraq.cc index 06be955ca..b0c7b2eda 100644 --- a/skytraq.cc +++ b/skytraq.cc @@ -696,7 +696,7 @@ make_trackpoint(struct read_state* st, double lat, double lon, double alt) { auto* wpt = new Waypoint; - wpt->shortname = QString::asprintf("TP%04d", ++st->tpn); + wpt->shortname = QString("TP%1").arg(++st->tpn, 4, 10, QLatin1Char('0')); wpt->latitude = lat; wpt->longitude = lon; diff --git a/waypt.cc b/waypt.cc index 6cbd1c24f..e8f72709a 100644 --- a/waypt.cc +++ b/waypt.cc @@ -617,7 +617,7 @@ WaypointList::waypt_add(Waypoint* wpt) } else if (!wpt->notes.isNull()) { wpt->shortname = wpt->notes; } else { - wpt->shortname = QString::asprintf("WPT%03d", waypt_count()); + wpt->shortname = QString("WPT%1").arg(waypt_count(), 3, 10, QLatin1Char('0')); } } -- 2.30.2